package com.linewow.xhyy.nihaonew.activity;
import android.databinding.DataBindingUtil;
import android.support.v4.app.FragmentManager;
import android.util.Log;

import com.linewow.xhyy.nihaonew.R;
import com.linewow.xhyy.nihaonew.base.BaseFragmentActivity;
import com.linewow.xhyy.nihaonew.control.SearchBeginDataControl;
import com.linewow.xhyy.nihaonew.databinding.ActivitySearchBeginBinding;
import com.linewow.xhyy.nihaonew.event.MessageEvent;
import com.linewow.xhyy.nihaonew.inter.FinishCall;
import com.linewow.xhyy.nihaonew.inter.SureCall;

import org.simple.eventbus.EventBus;

/**
 * Created by LXR on 2016/8/30.
 */
public class SearchBeginActivity extends BaseFragmentActivity implements FinishCall {
    private String TAG="SearchBeginActivity";
    private ActivitySearchBeginBinding searchBeginBinding;
    private FragmentManager fm;
    private SearchBeginDataControl searchBeginDataControl;
    @Override
    public void initView() {
        super.initView();
        searchBeginBinding= DataBindingUtil.setContentView(SearchBeginActivity.this, R.layout.activity_search_begin);
        fm=getSupportFragmentManager();
        searchBeginDataControl=new SearchBeginDataControl(fm,SearchBeginActivity.this);

        searchBeginBinding.setControl(searchBeginDataControl);
        Log.e(TAG,"更改了");

        searchBeginDataControl.setSureCall(new SureCall() {
            @Override
            public void sureFinish() {
                String editString=searchBeginBinding.searchBeginInclude.toolbarSearchMid.getText().toString();
                Log.e(TAG,"打印字符串长度"+editString.length());
                if(editString.length()>0){
                    Log.e(TAG,"发送了");
                    EventBus.getDefault().post(new MessageEvent(editString),"Search");
                }
            }
        });


    }

    @Override
    public void initList() {
        super.initList();

    }

    @Override
    public void initData() {
        super.initData();
    }

    /**
     * 退出界面
     */
    @Override
    public void actFinish() {
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

    }
}
